package pagereplace;

import java.util.ArrayList;

import javafx.fxml.FXML;
import javafx.scene.control.Button;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.fxml.Initializable;
import javafx.scene.control.cell.PropertyValueFactory;

public class PageReplaceControl {
	@FXML
	private Button btn;
	@FXML
	private TableView tab;
	@FXML
	private TableColumn tc1,tc2,tc3,tc4;
	
	ObservableList<HitRate> hang = FXCollections.observableArrayList();
	ArrayList<Integer> p = new ArrayList<Integer>();
	int []page = new int[400];
	PageAddress p_a = new PageAddress();
	public void PageAdd() {
		p = p_a.getPage();
		int i = 0;
		for(int pp : p) {
			page[i] = pp;
			i++;
		}
	}
	
	public void Btn_Click() {
		PageAdd();
		TabAdd();
		ShowTab();
	}
	
	public void TabAdd() {
		for(int row = 4; row <= 40; row++) {
			hang.add(new HitRate(page, row));
		}
	}
	
	public void ShowTab() {
		tc1.setCellValueFactory(new PropertyValueFactory("num"));
		tc2.setCellValueFactory(new PropertyValueFactory("hitOPT"));
		tc3.setCellValueFactory(new PropertyValueFactory("hitFIFO"));
		tc4.setCellValueFactory(new PropertyValueFactory("hitLRU"));
		
		tab.setItems(hang);
	}
	
	
}
